package com.control.qct.businesssteward.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.adapter.ComplimentaryStatisticAdapter;
import com.control.qct.businesssteward.base.BaseFragment;
import com.control.qct.businesssteward.model.ComplimentaryStatisticModel;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 赠品统计表
 * Created by Administrator on 2017/12/27 0027.
 */

public class ComplimentaryStatisticFragment extends BaseFragment {
    @BindView(R.id.rv_complimentary_statistic)
    RecyclerView mRvComplimentaryStatistic;

    private List<ComplimentaryStatisticModel> mComplimentaryStatisticModelList;
    private int max1;
    private int max2;
    private int max3;
    private ComplimentaryStatisticAdapter mComplimentaryStatisticAdapter;

    @Override
    protected View initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
            savedInstanceState) {
        return inflater.inflate(R.layout.fragment_complimentary_statistic, container, false);
    }

    @Override
    protected void initView(View view) {
        activity.setTitle("赠品统计表");
        mComplimentaryStatisticModelList = new ArrayList<>();
        mComplimentaryStatisticModelList.add(new ComplimentaryStatisticModel("西瓜", 252, 342, 266));
        mComplimentaryStatisticModelList.add(new ComplimentaryStatisticModel("桃子", 313, 456, 212));
        mComplimentaryStatisticModelList.add(new ComplimentaryStatisticModel("栗子", 215, 223, 441));
        mComplimentaryStatisticModelList.add(new ComplimentaryStatisticModel("苹果", 332, 312, 332));
        mComplimentaryStatisticModelList.add(new ComplimentaryStatisticModel("葡萄", 254, 418, 223));
        for (int i = 0; i < mComplimentaryStatisticModelList.size(); i++) {
            if (max1 < mComplimentaryStatisticModelList.get(i).getNum1()) {
                max1 = mComplimentaryStatisticModelList.get(i).getNum1() + 50;
            }
            if (max2 < mComplimentaryStatisticModelList.get(i).getNum2()) {
                max2 = mComplimentaryStatisticModelList.get(i).getNum2() + 50;
            }
            if (max3 < mComplimentaryStatisticModelList.get(i).getNum3()) {
                max3 = mComplimentaryStatisticModelList.get(i).getNum3() + 50;
            }
        }
        mRvComplimentaryStatistic.setLayoutManager(new LinearLayoutManager(activity));
        mComplimentaryStatisticAdapter = new ComplimentaryStatisticAdapter(mComplimentaryStatisticModelList);
        mRvComplimentaryStatistic.setAdapter(mComplimentaryStatisticAdapter);
        mComplimentaryStatisticAdapter.setMax1(max1);
        mComplimentaryStatisticAdapter.setMax2(max2);
        mComplimentaryStatisticAdapter.setMax3(max3);
    }
}
